//
//  WMEMoreTableViewCell.m
//  everyDay_duiTang
//
//  Created by 恩叔 on 16/2/2.
//  Copyright © 2016年 enshu. All rights reserved.
//

#import "WMEMoreTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>

#pragma mark - 赞更多的cell

@interface WMEMoreTableViewCell ()
@property (nonatomic, retain)UIImageView *userImg;
@property (nonatomic, retain)UILabel *userName;
@property (nonatomic, retain)UILabel *line;

@end


@implementation WMEMoreTableViewCell
- (void)dealloc
{
    [_moreModel release];
    [_userImg release];
    [_userName release];
    [_line release];
    [super dealloc];
}
#pragma mark-初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //用户图片
        self.userImg = [[UIImageView alloc] init];
//        _userImg.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_userImg];
        [_userImg release];
        
        //用户名
        self.userName = [[UILabel alloc] init];
//        _userName.backgroundColor = [UIColor yellowColor];
        _userName.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_userName];
        [_userName release];
        
        //线
        self.line = [[UILabel alloc] init];
        _line.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_line];
        [_line release];
    }
    return self;
}
#pragma mark - 重写setting方法
- (void)setMoreModel:(WMEFirstPageModel *)moreModel
{
    if (_moreModel != moreModel) {
        [_moreModel release];
        _moreModel = [moreModel retain];
        [_userImg sd_setImageWithURL:[NSURL URLWithString:_moreModel.supportAvatar]];
        _userName.text = _moreModel.supportName;
    }
}

#pragma mark -布局函数
- (void)layoutSubviews
{
    [super layoutSubviews];
    __block __typeof(&*self)ws = self;
    [_userImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(40, 40));
        make.left.equalTo(ws.mas_left).with.offset(10);
        make.top.equalTo(ws.mas_top).with.offset(10);
        make.bottom.equalTo(ws.mas_bottom).with.offset( -10);
    }];
    _userImg.layer.cornerRadius = 20;
    _userImg.contentMode = UIViewContentModeScaleAspectFill;
    _userImg.clipsToBounds = YES;
    [_userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(40, 40));
        make.centerY.equalTo(_userImg.mas_centerX);
        make.left.equalTo(_userImg.mas_right).with.offset(10);
        make.right.equalTo(ws.mas_right).with.offset(-10);
    }];
    [_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(ws.mas_bottom).with.offset(1);
        make.left.equalTo(ws.mas_left).with.offset(50);
        make.right.equalTo(ws.mas_right).with.offset(0);
    }];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
